package com.cq.hd.product.controller;

import com.cq.hd.common.pagination.Page;
import com.cq.hd.common.response.Result;
import com.cq.hd.common.response.ResultGenerator;
import com.cq.hd.product.api.TbActiveRedPacketApi;
import com.cq.hd.product.api.dto.ReceiveRedPacketDto;
import com.cq.hd.product.api.dto.RedPacketStatisticsDto;
import com.cq.hd.product.api.vo.ActiveRedPacketVo;
import com.cq.hd.product.service.TbActiveRedPacketService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 活动红包表 前端控制器
 * </p>
 *
 * @author mYunYu
 * @since 2023-11-23
 */
@RestController
public class TbActiveRedPacketController implements TbActiveRedPacketApi {

    @Autowired
    private TbActiveRedPacketService activeRedPacketService;

    @ApiOperation(value = "领取红包")
    @ApiImplicitParam(name = "receiveRedPacketDto", value = "实体", paramType = "body", dataType = "ReceiveRedPacketDto")
    @Override
    public Result<Boolean> receive(@RequestBody ReceiveRedPacketDto receiveRedPacketDto) {
        return ResultGenerator.success(activeRedPacketService.receive(receiveRedPacketDto));
    }

    @ApiOperation(value = "红包中心的红包明细分页列表")
    @ApiResponse(response = ActiveRedPacketVo.class, code = 200, message = "接口返回对象参数")
    @Override
    public Result<Page<ActiveRedPacketVo>> pageValidRedPacket(RedPacketStatisticsDto redPacketStatisticsDto) {
        return ResultGenerator.success(activeRedPacketService.pageValidRedPacket(redPacketStatisticsDto));
    }

}
